---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  labels:
    heritage: deckhouse
    module: deckhouse
  name: projecttemplates.deckhouse.io
spec:
  group: deckhouse.io
  names:
    kind: ProjectTemplate
    listKind: ProjectTemplateList
    plural: projecttemplates
    singular: projecttemplate
  scope: Cluster
  versions:
    - name: v1alpha1
      additionalPrinterColumns:
        - jsonPath: .status.ready
          name: Ready
          type: boolean
      schema:
        openAPIV3Schema:
          description: |
            Describes the project template.

            This resource is referenced by the [Project](cr.html#project) custom resource.
          properties:
            spec:
              required: ["parametersSchema", "resourcesTemplate"]
              properties:
                parametersSchema:
                  type: object
                  required: ["openAPIV3Schema"]
                  description: |
                    One of parameters schema to validate parameters of a project.

                    For now only OpenAPI v3 schema is supported.
                  properties:
                    openAPIV3Schema:
                      type: object
                      additionalProperties:
                        x-kubernetes-preserve-unknown-fields: true
                      description: |
                        OpenAPI specification for [parameters](#project-v1alpha2-spec-parameters).

                        This is used to check the validity of the parameters that are passed when creating a new project.
                resourcesTemplate:
                  description: |
                    A template that defines resources in the [`go template`](https://pkg.go.dev/text/template) format to be created when setting up a new project.

                    Templates are fully compatible with all [`helm` functions](https://helm.sh/docs/chart_template_guide/function_list/).

                    Read more about [creating an isolated Environment...](usage.html#creating-a-project)

                    The following parameters are available in templates:
                    - `{{ .projectName }}` — the name of the `Project` for which the template is being rendered.
                    - `{{ .projectTemplateName }}` — the name of the `ProjectTemplate`.
                    - `{{ .parameters }}` — a dictionary of custom values, described in the [.spec.parametersSchema](cr.html#projecttemplate-v1alpha1-spec-parametersschema) and defined in the [.spec.parameters](cr.html#project-v1alpha2-spec-parameters).

                    > **Note!** Specifying `.metadata.namespace` fields for objects is optional,
                    > as this field is automatically set with the name of the created project.
                  type: string
              type: object
            status:
              properties:
                message:
                  description: Message indicating the cause of the current status.
                  type: string
                ready:
                  description: Whether the template is ready to use. Indicates that the template has been successfully validated.
                  type: boolean
              type: object
          type: object
      served: true
      storage: true
      subresources:
        status: {}
